<?php
class AdTimesLogNew extends BaseModel
{
    protected $res;
    protected $redis_key="admin_";
    public function getSource()
    {
        return "ad_times_log_new";
    }
    public function initialize()
    {
        parent::initialize();
    }


    public function get_list($params,$method='list'){

        $page = intval($params['page']);
        $size = intval($params['limit']);
        if ($page > 0) {
            $page = ($page - 1) * $size;
        }
        $conditions = "type = 2";
        if(isset($params['keywords']) && !empty($params['keywords'])){
            $conditions .= " and name like '%{$params['keywords']}%'";
        }
        if($method == 'list'){
            $cate_list = $this::find(
                array(
                    $conditions,
                    "order"  => 'date desc',
                    'limit'  => $size,
                    'offset' => $page
                ))->toarray();
            return $cate_list;
        }else{
            $cate_list = $this::count(
                array(
                    $conditions,
                    "order"  => 'date desc',
                ));
            return $cate_list;
        }
    }


}
